package com.klb.model;

import javax.persistence.*;
import java.sql.Date;

/**
 * Created by fujia on 2016/7/2.
 */
@Entity
@Table(name = "bbs_article", schema = "knowlogebase", catalog = "")
public class BbsArticle {
    private int articleId;
    private String title;
    private String text;
    private int userId;
    private int blockId;
    private int commentNumber;
    private int praiseNumber;
    private String tags;
    private Date dateAdded;

    @Id
    @Column(name = "article_id", nullable = false)
    public int getArticleId() {
        return articleId;
    }

    public void setArticleId(int articleId) {
        this.articleId = articleId;
    }

    @Basic
    @Column(name = "title", nullable = false, length = 50)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Column(name = "text", nullable = false, length = 500)
    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Basic
    @Column(name = "user_id", nullable = false)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "block_id", nullable = false)
    public int getBlockId() {
        return blockId;
    }

    public void setBlockId(int blockId) {
        this.blockId = blockId;
    }

    @Basic
    @Column(name = "comment_number", nullable = false)
    public int getCommentNumber() {
        return commentNumber;
    }

    public void setCommentNumber(int commentNumber) {
        this.commentNumber = commentNumber;
    }

    @Basic
    @Column(name = "praise_number", nullable = false)
    public int getPraiseNumber() {
        return praiseNumber;
    }

    public void setPraiseNumber(int praiseNumber) {
        this.praiseNumber = praiseNumber;
    }

    @Basic
    @Column(name = "tags", nullable = false, length = 50)
    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    @Basic
    @Column(name = "date_added", nullable = false)
    public Date getDateAdded() {
        return dateAdded;
    }

    public void setDateAdded(Date dateAdded) {
        this.dateAdded = dateAdded;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;

        BbsArticle articles = (BbsArticle) object;

        if (articleId != articles.articleId) return false;
        if (userId != articles.userId) return false;
        if (blockId != articles.blockId) return false;
        if (commentNumber != articles.commentNumber) return false;
        if (praiseNumber != articles.praiseNumber) return false;
        if (title != null ? !title.equals(articles.title) : articles.title != null) return false;
        if (text != null ? !text.equals(articles.text) : articles.text != null) return false;
        if (tags != null ? !tags.equals(articles.tags) : articles.tags != null) return false;
        if (dateAdded != null ? !dateAdded.equals(articles.dateAdded) : articles.dateAdded != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = articleId;
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (text != null ? text.hashCode() : 0);
        result = 31 * result + userId;
        result = 31 * result + blockId;
        result = 31 * result + commentNumber;
        result = 31 * result + praiseNumber;
        result = 31 * result + (tags != null ? tags.hashCode() : 0);
        result = 31 * result + (dateAdded != null ? dateAdded.hashCode() : 0);
        return result;
    }
}
